package com.kcl.dfss;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.TextView;


public class HistoryActivity extends Activity {
	
	private LinearLayout layout_history_back;
	private TextView his_time,his_mileage;
//	private TextView his_warn;
	private int htime = 0,hmileage = 0,hwarn = 0;
	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_history);
		
		his_time = (TextView) findViewById(R.id.his_time);
		his_mileage = (TextView) findViewById(R.id.his_mileage);
//		his_warn = (TextView) findViewById(R.id.his_warn);
		
		layout_history_back = (LinearLayout) findViewById(R.id.layout_history_back);
		layout_history_back.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				finish();
			}
		});
		
		//设置统计文字字体颜色
		String stime = String.format(getResources().getString(R.string.history2), htime);
		int ftime = stime.indexOf(String.valueOf(htime));
		int fend = ftime+String.valueOf(htime).length();
		SpannableStringBuilder style1 = new SpannableStringBuilder(stime);
		style1.setSpan(new ForegroundColorSpan(Color.parseColor("#4F964B")), ftime, fend, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
		his_time.setText(style1);
		
		String smileage = String.format(getResources().getString(R.string.history3), hmileage);
		int fmileage = smileage.indexOf(String.valueOf(hmileage));
		int fend2 = fmileage+String.valueOf(hmileage).length();
		SpannableStringBuilder style2 = new SpannableStringBuilder(smileage);
		style2.setSpan(new ForegroundColorSpan(Color.parseColor("#4B8796")), fmileage, fend2, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
		his_mileage.setText(style2);
		
		/*String swarn = String.format(getResources().getString(R.string.history4), hwarn);
		int fwarn = swarn.indexOf(String.valueOf(hwarn));
		int fend3 = fwarn+String.valueOf(hwarn).length();
		SpannableStringBuilder style3 = new SpannableStringBuilder(swarn);
		style3.setSpan(new ForegroundColorSpan(Color.parseColor("#A4AC4C")), fwarn, fend3, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
		his_warn.setText(style3);*/
	}
	
	
}
